package com.liang.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liang.entity.CNews;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 李昂
 * @since 2021-01-14
 */
public interface CNewsMapper extends BaseMapper<CNews> {

    //获取新闻列表
    @Select("select nid, title,time,looks from c_news")
    List<CNews> getNewsList();

    //获取新闻内容
    @Select("select container from c_news where nid=#{id}")
    String getContainer(@Param("id") int id);

    //获取查看总数
    @Select("select looks from c_news where nid=#{id}")
    int getLooks(@Param("id") int id);

    //更新查看数据
    @Update("update c_news set looks = looks+1 where nid=#{id} and looks=#{look}")
    boolean updateLook(@Param("id") int id, @Param("look") int look);

}
